<script>

import { mapMutations } from 'vuex';

export default {
  data() {
    return {
      user: {
        name: 'Admin',
        pwd: '123'
      }
    }
  },
  methods: {
    ...mapMutations(['setLoginUser']),
    login() {
      this.axios({
        method: 'get',
        url: 'Sign',
        params: {
          loginname: this.user.name,
          loginpwd: this.user.pwd
        }
      }).then(response => {
        //登录成功 设置保存用户信息到 vuex 中
        this.setLoginUser(response.data);
        // post 
        this.$router.push({
          path: '/'
        })
      })



    }
  },
}
</script>

<template>
  <div>
    <form>
      账户：<input type="text" v-model="user.name"> <br>
      密码：<input type="password" v-model="user.pwd"> <br>
      <input type="button" value="登录" @click="login">
    </form>
  </div>
</template>

<style>
</style>